package com.zjp;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import org.junit.jupiter.api.Test;


public class ImmutableTest {

    @SuppressWarnings("deprecation")
    @Test
    public void t1() {

        String[] str = {"C", "A", "B"};
        // 不可变集合
        ImmutableSet<String> immutableSet = ImmutableSet.<String>builder().add(str).build();
        immutableSet.add("D");
    }

    @SuppressWarnings("deprecation")
    @Test
    public void t2() throws UnsupportedOperationException {

        String[] str = {"1", "2", "3"};

        ImmutableList<String> immutableList = ImmutableList.<String>builder().add(str).build();

        immutableList.add("5");


        ImmutableList<String> of = ImmutableList.of("A", "V", "A");

        of.add("D");
        System.out.println("T2");
    }


    @SuppressWarnings("deprecation")
    @Test
    public void t3() {
        ImmutableMap<String, String> of = ImmutableMap.of("A", "1", "B", "2");
        of.put("C", "3");
    }

}
